<?php
require_once 'lib/controllerWithoutGetOrPost.php';
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past

/**
 * Add a new publication person entry
 *
 * @return string
 * @param mixed $personid
 * @param mixed $publicationid
 */
function insertNewPublicationPerson($personid, $publicationid) {
    global $db;
    $personid = $db->escape($personid);
    $publicationid = $db->escape($publicationid);
    $addedon = gmdate("Y-m-j H:i:s", time() + 3600*12);
    $sql = <<< EOT
        INSERT INTO
            PublicationPerson (PersonID, PublicationID, AddedOn)
        VALUES
            ($personid, $publicationid, '$addedon')

EOT;
    $db->query($sql);
    $insertID = $db->insertID();
    return $db->unescape($insertID);
}
$personid = insertNewPublicationPerson($_POST["personid"], $_POST["publicationid"]);
?>
